package cn.bdqn.demo2.controller;

import cn.bdqn.demo2.entitiy.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@PropertySource("classpath:database.properties")
public class HelloSpringBoot {
    @Value("${driver}")
    private String name;
    @Value("${age}")
    private int age;
    @Resource
    private User user;
    @RequestMapping("/test1")
    public String test1(){
        return "Hello SpringBoot!";
    }
    @RequestMapping("/test2")
    public String test2(){
        return "Hello SpringBoot!name="+name+",age="+age;
    }
    @RequestMapping("/test3")
    public String test3(){
        return "Hello SpringBoot!name="+user.getUname()+",age="+user.getAge();
    }
}
